{% extends "base.html" %}
{% block header_ext %}
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css" />
<link rel="stylesheet" type="text/css" href="/static/worldeditor/css/worldeditor.css" />
{% endblock %}
{% block content %}
<h1>{{ title }}</h1>
<div>{{ desc }}</div>
<div id="content-main">
    <form action="submit.html" method="post">
        {% csrf_token %}
        <div>
            <fieldset class="module aligned">
                {% for field in data %}
                <div class="form-row">
                    {{ field.label_tag }}{{ field }}
                    {% if field.help_text %}
                    <br><br>
                    <ul class="helplist"><li>{{ field.help_text }}</li></ul>
                    {% endif %}
                    {{ field.errors }}
                </div>
                {% endfor %}
            </fieldset>
            <input type="hidden" name="_record" value="{{ record }}" />
            <input type="hidden" name="_page" value="{{ page }}" />
            <div class="submit-row">
                {% if can_delete %}
                <input type="submit" name="_delete" value="删除" class="delete-box" />
                {% endif %}
                <input type="submit" name="_back" value="返回" />
                <input type="submit" name="_continue" value="保存并继续编辑" />
                <input type="submit" name="_save" value="保存" class="default" />
            </div>
        </div>
    </form>
    {% if dialogue_key %}
    <form action="../dialogue_sentences/add.html" method="post">
        {% csrf_token %}
        <input type="hidden" name="_dialogue_key" value="{{ dialogue_key }}" />
        <input type="hidden" name="_back_record" value="{{ record }}" />
        <input type="hidden" name="_back_page" value="{{ page }}" />
        <div class="object-tools">
            <input type="submit" name="_add_sentence" value="添加 {{ sentence_title }}" class="add-box" />
        </div>
    </form>
    <div class="module" id="changelist">
        <div class="results">
            <table id="result_list">
                <thead>
                    <tr>
                        {% for field in fields %}
                        <th scope="col" class="sortable">
                            <div class="text">{{ field.verbose_name|upper }}</div>
                        </th>
                        {% endfor %}
                    </tr>
                </thead>
                <tbody>
                    {% for sentence in sentences %}
                        <tr class="{% cycle 'row1' 'row2' %}">
                            {% for item in sentence.items %}
                            <td class="field">
                                {% if forloop.first %}
                                    <a class="table_head" href="/worlddata/editor/dialogues/dialogue_sentences/form.html?_dialogue_key={{ dialogue_key }}&_record={{ sentence.pk }}&_back_page={{ page }}&_back_record={{ record }}">
                                {% endif %}
                                {{ item }}
                                {% if forloop.first %}
                                    </a>
                                {% endif %}
                            </td>
                        {% endfor %}
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    {% endif %}
</div>
{% endblock content %}